<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <div>
        <div>
            <input type="hidden" name="id" lay-verify="required"
                   class="layui-input" th:value="${model.id}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">学号</label>
        <div class="layui-input-block">
            <input type="text" name="username"
                   lay-verify="required" lay-reqtext="学号不能为空" placeholder="请输入学号" value=""
                   class="layui-input" th:value="${model.username}" disabled>
            <tip>学号不允许修改</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name"
                   lay-verify="required" lay-reqtext="姓名不能为空" placeholder="请输入姓名" value=""
                   class="layui-input" th:value="${model.name}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">院系</label>
        <div class="layui-input-block">
            <select name="department">
                <option value=""></option>
                <option value="会计学院">会计学院</option>
                <option value="信息工程学院" selected="">信息工程学院</option>
                <option value="人文学院">人文学院</option>
                <option value="工商管理系">工商管理系</option>
                <option value="法律系">法律系</option>
                <option value="传播系">传播系</option>
                <option value="艺术设计系">艺术设计系</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">专业班级</label>
        <div class="layui-input-block">
            <input type="text" name="majorClazz"
                   lay-verify="required" lay-reqtext="专业班级能为空" placeholder="请输入专业班级" value=""
                   class="layui-input" th:value="${model.majorClazz}">
        </div>
    </div>


    <div>
        <div>
            <input type="hidden" name="domitoryId" class="layui-input" id="domitoryId" required>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">e-mail</label>
        <div class="layui-input-block">
            <input type="email" name="email" placeholder="请输入邮箱" value=""
                   class="layui-input" th:value="${model.email}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="number" name="phone" placeholder="请输入手机号" value=""
                   class="layui-input" th:value="${model.phone}">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script th:src="@{/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js?v=1.0.4}" charset="utf-8"></script>
<script lang="JavaScript", th:inline="javascript">
    layui.use(['form', 'laydate', 'tableSelect'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            laydate = layui.laydate,
            tableSelect = layui.tableSelect;


        //监听提交
        form.on('submit(saveBtn)', function (data) {

            console.log(JSON.stringify(data.field));

            $.ajax({
                url: "../../api-v1/student/edit",
                method: "post",
                data: JSON.stringify(data.field),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                    var index = layer.alert(result.msg, {
                        title: '提交信息',
                        icon: 1
                    }, function () {
                        // 关闭弹出层
                        layer.close(index);

                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        // 重载表格
                        window.parent.location.reload();
                    });
                }
            });
            return false;
        });
    });
</script>
</body>
</html>